<?php
namespace app\common\model;

use think\Model;

class SelfTakeModel extends Model {
    // 完整数据表名
    protected $table              = 'self_take';
    // 自动时间戳
    protected $autoWriteTimestamp = true;
    // 时间输出格式
    protected $type = [
        'self_take_create_time' => 'timestamp',
        'self_take_update_time' => 'timestamp',
    ];

    //商户自提点列表
    public static function self_take_sel($where, $page_number){
        $self_take = SelfTakeModel::where($where)->order('self_take_create_time desc')->paginate($page_number);
        if(!$self_take){
            return false;
        }
        return $self_take;
    }

    //添加自提点数据
    public static function self_take_add($data){
        $self_take = SelfTakeModel::create($data);
        if(!$self_take){
            return false;
        }
        return $self_take;
    }

    //修改某个商户自提点
    public static function self_take_edit($data, $where){
        $self_take = SelfTakeModel::update($data, $where);
        if(!$self_take){
            return false;
        }
        return $self_take;
    }

    //删除商户自提点
    public static function self_take_del($where){
        $self_take = SelfTakeModel::destroy($where);
        if(!$self_take){
            return false;
        }
        return true;
    }
}